﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using System.Data;
using System.Collections;
using KPIS.GERP.ESS.BLL;
using KPIS.GERP.ESS.MODEL;

namespace KPIS.GERP.ESS.APP.App_UI.UserControls
{
    public partial class RequestAbsences : System.Web.UI.UserControl
    {
        private B_HrmRequest reqBLL = new B_HrmRequest();
        private B_HrmPositions posBLL = new B_HrmPositions();
        private B_HrmEmployees empBLL = new B_HrmEmployees();
        private B_MessageSend mesBLL = new B_MessageSend();
        private B_MessageReply replyBLL = new B_MessageReply();

        private const int ItemsPerRequest = 10;

        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected bool IsUserControlPostBack
        {
            get
            {                
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {                
                this.ViewState.Add("IsUserControlPostBack", true);
            }
        }
       
        public void LoadDataEditInsert(int Sequence)
        {
            DataSet ds = null;
            DataTable dt = null;

            if (Sequence > 0)
            {
                OnUpdateCmdUI("EDIT");
                ds = reqBLL.GetRequestAbsences(Sequence, (int?)null, ""); //empBLL.GetEmployeeInfo(Int32.Parse(Session["EmpSeq"].ToString()), "");

                if (ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];
                    lblRefNo.Text = dt.Rows[0]["REF_NO"].ToString();
                    lblCreatedDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["CREATED_WHEN"]);
                    lblName.Text = dt.Rows[0]["FULL_NAME"].ToString();
                    lblPosName.Text = dt.Rows[0]["POS_NAME"].ToString();
                    lblJobSiteName.Text = dt.Rows[0]["JOB_SITE_NAME"].ToString();
                    cmbAbsenceType.Items.Add(new RadComboBoxItem(dt.Rows[0]["ABSENCE_TYPE_NAME"].ToString(), dt.Rows[0]["ABSENCE_TYPE_SEQ"].ToString()));
                    cmbAbsenceType.SelectedValue = dt.Rows[0]["ABSENCE_TYPE_SEQ"].ToString();
                    txtStartDate.SetValue(dt.Rows[0]["START_DATE"]);
                    rdoStartTime.SelectedValue = dt.Rows[0]["START_TIME"].ToString();
                    txtEndDate.SetValue(dt.Rows[0]["END_DATE"]);
                    rdoEndTime.SelectedValue = dt.Rows[0]["END_TIME"].ToString();
                    txtCountDate.Text = dt.Rows[0]["COUNT_DATE"].ToString();
                    txtContactAddress.Text = dt.Rows[0]["CONTACT_ADDRESS"].ToString();
                    cmbAppSeq.Items.Add(new RadComboBoxItem(dt.Rows[0]["APPROVED_NAME"].ToString(), dt.Rows[0]["APPROVED_BY"].ToString()));
                    cmbAppSeq.SelectedValue = dt.Rows[0]["APPROVED_BY"].ToString();                   
                    
                    txtReason.Text = dt.Rows[0]["ABSENCE_REASON"].ToString();
                }
            }
            else
            {
                OnUpdateCmdUI("ADDNEW");
                ds = empBLL.GetEmployeeInfo(Int32.Parse(Session["EmpSeq"].ToString()), "");

                if (ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];
                    lblRefNo.Text = "ต้องบันทึกข้อมูลก่อน";
                    lblCreatedDate.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Today);
                    lblName.Text = dt.Rows[0]["FULL_NAME"].ToString();
                    lblPosName.Text = dt.Rows[0]["POS_NAME"].ToString();
                    lblJobSiteName.Text = dt.Rows[0]["JOB_SITE_NAME"].ToString();
                    lblApprovedDate.Text = "รอการพิจารณา";
                    lblStatusName.Text = "รอการพิจารณา";
                }
            }
        }
        public void LoadDataView(int Sequence)
        {
            OnUpdateCmdUI("VIEW");
            LoadData(Sequence);
        }
        public void LoadData(int Sequence)
        {
            DataSet ds = reqBLL.GetRequestAbsences(Sequence, (int?)null, ""); //empBLL.GetEmployeeInfo(Int32.Parse(Session["EmpSeq"].ToString()), "");
            DataTable dt = null;

            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    lblAbsenceSeq.Text = dt.Rows[0]["ABSENCE_SEQ"].ToString();
                    lblSendSeq.Text = dt.Rows[0]["SEND_SEQ"].ToString();
                    lblEmpSeq.Text = dt.Rows[0]["EMP_SEQ"].ToString();
                    lblRefNo.Text = dt.Rows[0]["REF_NO"].ToString();
                    lblCreatedDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["CREATED_WHEN"]);
                    lblName.Text = dt.Rows[0]["FULL_NAME"].ToString();
                    lblPosName.Text = dt.Rows[0]["POS_NAME"].ToString();
                    lblJobSiteName.Text = dt.Rows[0]["JOB_SITE_NAME"].ToString();
                    lblAbsenceTypeName.Text = dt.Rows[0]["ABSENCE_TYPE_NAME"].ToString();
                    lblStartDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["START_DATE"]);
                    rdoStartTime.SelectedValue = dt.Rows[0]["START_TIME"].ToString();
                    lblEndDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["END_DATE"]);
                    rdoEndTime.SelectedValue = dt.Rows[0]["END_TIME"].ToString();
                    lblCountDate.Text = string.Format("{0:###.##}", dt.Rows[0]["COUNT_DATE"]);
                    lblAddress.Text = dt.Rows[0]["CONTACT_ADDRESS"].ToString();
                    lblApprovedBy.Text = dt.Rows[0]["APPROVED_BY"].ToString();
                    lblApprovedName.Text = dt.Rows[0]["APPROVED_NAME"].ToString();
                    lblApprovedDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["APPROVED_DATE"]);
                    lblRemarks.Text = dt.Rows[0]["ABSENCE_REASON"].ToString();
                    lblStatusName.Text = dt.Rows[0]["APPROVED_STATUS_NAME"].ToString();
                    lblStatus.Text = dt.Rows[0]["APPROVED_STATUS"].ToString();
                    lblApprovedReason.Text = dt.Rows[0]["APPROVED_REASON"].ToString();
                    rdoApproveStatus.SelectedValue = dt.Rows[0]["APPROVED_STATUS"].ToString();
                    txtApproveDate.SetValue(dt.Rows[0]["APPROVED_DATE"]);
                    txtApprovedReason.Text = dt.Rows[0]["APPROVED_REASON"].ToString();
                    
                }
            }
        }
        public void LoadDataApproved(int Sequence, bool bEdit)
        {
            OnUpdateCmdUI("APPROVED");            
            LoadData(Sequence);
            // กรณีพิจารณาไปแล้ว ************************************
            bool bApproved = lblStatus.Text == "W";
            bool bAgree = lblStatus.Text == "1";

            btnUpdate.Visible = bApproved && bEdit;
            lblStatusName.Visible = !bApproved;
            rdoApproveStatus.Visible = bApproved;
            txtApproveDate.Visible = bApproved;
            lblApprovedDate.Visible = !bApproved;
            //txtApprovedReason.Visible = bApproved;
            lblApprovedReason.Visible = !bApproved;
            //**************************************************
            UpdateSendMessageStatus(lblSendSeq.Text, SystemInfo._ReadMessage);
        }
        private void OnUpdateCmdUI(string Mode)
        {
            bool bViewMode = Mode == "VIEW";
            bool bAddNewMode = Mode == "ADDNEW";
            bool bEditMode = Mode == "EDIT";
            bool bApprovedMode = Mode == "APPROVED";
            bool bNull = Mode == "";

            btnAddnew.Visible = bAddNewMode;
            btnUpdate.Visible = bEditMode || bApprovedMode;
            btnCancel.Visible = !bViewMode && !bApprovedMode;
            btnBackHome.Visible = bViewMode;
            btnEditMode.Visible = bViewMode;
            btnViewRequest.Visible = bApprovedMode;

            cmbAbsenceType.Visible = !bViewMode && !bApprovedMode;
            txtStartDate.Visible = !bViewMode && !bApprovedMode;
            rdoStartTime.Enabled = !bViewMode && !bApprovedMode;
            txtEndDate.Visible = !bViewMode && !bApprovedMode;
            rdoEndTime.Enabled = !bViewMode && !bApprovedMode;
            txtCountDate.Visible = !bViewMode && !bApprovedMode;
            txtContactAddress.Visible = !bViewMode && !bApprovedMode;
            cmbAppSeq.Visible = !bViewMode && !bApprovedMode;
            txtReason.Visible = !bViewMode && !bApprovedMode;
            txtApproveDate.Visible = bApprovedMode;
            rdoApproveStatus.Visible = bApprovedMode;
            //txtApprovedReason.Visible = bApprovedMode;

            lblAbsenceTypeName.Visible = bViewMode || bApprovedMode;
            lblStartDate.Visible = bViewMode || bApprovedMode;
            lblEndDate.Visible = bViewMode || bApprovedMode;
            lblCountDate.Visible = bViewMode || bApprovedMode;
            lblAddress.Visible = bViewMode || bApprovedMode;
            lblApprovedName.Visible = bViewMode || bApprovedMode;
            lblApprovedDate.Visible = !bApprovedMode;
            lblRemarks.Visible = bViewMode || bApprovedMode;
            lblStatusName.Visible = !bApprovedMode;
            lblApprovedReason.Visible = bViewMode;
        }
        private static string GetStatusMessage(int offset, int total)
        {
            if (total <= 0)
                return "ไม่มีข้อมูล";

            return String.Format("รายการที่ <b>1</b>-<b>{0}</b> จากทั้งหมด <b>{1}</b> รายการ", offset, total);
        }
        protected void ListApproverCombo()
        {
            DataSet ds = posBLL.GetPositionUpper(Int32.Parse(Session["EmpSeq"].ToString()), (int?)null, "");
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                cmbAppSeq.DataSource = dt;
                cmbAppSeq.DataBind();
            }
        }
        protected void UpdateSendMessageStatus(string strSendSeq, string strMessageStatus)
        {
            string strEmpID = Session["EmpSeq"].ToString();
            M_MessageSend info = new M_MessageSend();

            info.send_seq = Convert.ToInt32(strSendSeq);
            info.message_status = strMessageStatus;
            info.updated_by = Int32.Parse(strEmpID);
            info.updated_when = DateTime.Now;

            mesBLL.UpdateMessageStatus(info);
        }

        protected void cmbAppSeq_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
        {
            cmbAppSeq.Items.Clear();

            DataSet ds = posBLL.GetPositionUpper(Int32.Parse(Session["EmpSeq"].ToString()), (int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
            }
            int itemOffset = e.NumberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
            e.EndOfItems = (endOffset == dt.Rows.Count);
            int j = 0;
            for (int i = itemOffset; i < endOffset; i++)
            {
                cmbAppSeq.Items.Add(new RadComboBoxItem(dt.Rows[i]["FULL_NAME"].ToString(), dt.Rows[i]["UPPER_EMP_SEQ"].ToString()));

                TableRow tr = new TableRow();

                TableCell tdPosName = new TableCell();
                Label lblPosName = new Label();
                lblPosName.Text = dt.Rows[i]["FULL_NAME"].ToString();
                tdPosName.Width = Unit.Pixel(150);
                tdPosName.Controls.Add(lblPosName);
                tr.Cells.Add(tdPosName);

                TableCell tdClassSpecName = new TableCell();
                Label lblClassSpecName = new Label();
                lblClassSpecName.Text = dt.Rows[i]["EXEC_POS_NAME"].ToString();
                tdClassSpecName.Width = Unit.Pixel(100);
                tdClassSpecName.Controls.Add(lblClassSpecName);
                tr.Cells.Add(tdClassSpecName);

                TableCell tdJobName = new TableCell();
                Label lblJobName = new Label();
                lblJobName.Text = dt.Rows[i]["JOB_SITE_NAME"].ToString();
                tdJobName.Width = Unit.Pixel(100);
                tdJobName.Controls.Add(lblJobName);
                tr.Cells.Add(tdJobName);

                ((Table)cmbAppSeq.Items[j].FindControl("tableApprover")).Controls.Add(tr);
                j++;
            }
            e.Message = GetStatusMessage(endOffset, dt.Rows.Count);
         
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (btnViewRequest.Visible)//กรณี ผู้อนุมัติเข้ามาดู
            {
                Forword();
                UpdateSendMessageStatus(lblSendSeq.Text, SystemInfo._ReplyMessage);
                reqBLL.UpdateAbsenceStatus(Int32.Parse(lblAbsenceSeq.Text)
                    , rdoApproveStatus.SelectedValue
                    , DateTime.Parse(txtApproveDate.GetStringValue())
                    , Int32.Parse(Session["EmpSeq"].ToString())
                    );
                ((Forms.TaskLists)this.Parent.Page).ViewRequest();
            }
            else
            {   // กรณีเจ้าตัวเข้ามาแก้ไข
                reqBLL.UpdateAbsence(Int32.Parse(lblAbsenceSeq.Text)
                    , cmbAbsenceType.SelectedValue
                    , Session["EmpSeq"].ToString()
                    , DateTime.Parse(txtStartDate.GetStringValue())
                    , rdoStartTime.SelectedValue
                    , DateTime.Parse(txtEndDate.GetStringValue())
                    , rdoEndTime.SelectedValue
                    , string.IsNullOrEmpty(txtCountDate.Text) ? 0 : decimal.Parse(txtCountDate.Text)
                    , txtContactAddress.Text.Trim()
                    , SystemInfo._WorkRecordStatus
                    , cmbAppSeq.SelectedValue
                    , ""
                    , (DateTime?)null
                    , txtReason.Text.Trim()
                    , Int32.Parse(Session["EmpSeq"].ToString()));
                LoadDataView(Int32.Parse(lblAbsenceSeq.Text));
            }
        }
        private void InsertSend(Nullable<int> ForwordSendSeq)
        {
            M_MessageSend sendInfo = new M_MessageSend();

            sendInfo.send_date = DateTime.Today;
            sendInfo.ref_no = mesBLL.GetNextSendRefNo("AB");
            sendInfo.send_text = "ใบลา";
            sendInfo.ref_type = "hrm_ps_absences";
            sendInfo.ref_seq = Int32.Parse(lblAbsenceSeq.Text);
            sendInfo.from_emp_seq = Convert.ToInt32(Session["EmpSeq"].ToString());            
            sendInfo.remarks = null;
            sendInfo.message_status = "0";

            if (ForwordSendSeq.HasValue)
            {
                sendInfo.send_seq = (int)ForwordSendSeq;
                sendInfo.to_emp_seq = Convert.ToInt32(cmbNextApprover.SelectedValue);
                sendInfo.updated_by = Convert.ToInt32(Session["EmpSeq"].ToString());
                sendInfo.updated_when = DateTime.Now;

                mesBLL.Update(sendInfo);                
            }
            else 
            {
                sendInfo.to_emp_seq = Convert.ToInt32(cmbAppSeq.SelectedValue);
                sendInfo.created_by = Convert.ToInt32(Session["EmpSeq"].ToString());
                sendInfo.created_when = DateTime.Now;

                mesBLL.Insert(sendInfo);
            }           
        }
        protected string CheckIsForword()
        {
            string strForwordSendSeq = null;
            string strSendSeq = lblSendSeq.Text;

            ESS.MODEL.M_MessageSend info = mesBLL.GetInfoFromFromSendSeq(strSendSeq);
            if (info != null)
            {
                strForwordSendSeq = info.send_seq.ToString();
            }

            return strForwordSendSeq;
        }
        private void Reply()
        {
            //================ insert message_reply ====================
            ESS.MODEL.M_MessageReply ReplyInfo = new ESS.MODEL.M_MessageReply();

            string strUserID = Session["EmpSeq"].ToString();

            ReplyInfo.reply_date = DateTime.Today;
            ReplyInfo.ref_no = null;
            ReplyInfo.reply_text = "เห็นสมควรให้ลา";
            ReplyInfo.from_emp_seq = Int32.Parse(strUserID);
            ReplyInfo.to_emp_seq = Int32.Parse(lblEmpSeq.Text);
            ReplyInfo.from_send_seq =Int32.Parse(lblSendSeq.Text);
            ReplyInfo.remarks = txtApprovedReason.Text;
            ReplyInfo.reply_type = rdoApproveStatus.SelectedValue;
            ReplyInfo.message_status = "0";
            ReplyInfo.created_by = Int32.Parse(strUserID);
            ReplyInfo.created_when = DateTime.Now;

            replyBLL.Insert(ReplyInfo);
        }
        private void Forword()
        {
            string strUserID = Session["EmpSeq"].ToString();
            string strSendSeq = lblSendSeq.Text;
            string strForwordSendSeq = null;
            string strReplyText = null;

            switch (rdoApproveStatus.SelectedValue)
            {
                case "0"://ไม่เห็นด้วย
                    strReplyText = txtApprovedReason.Text;
                    strForwordSendSeq = CheckIsForword();

                    if (!string.IsNullOrEmpty(strForwordSendSeq))
                    {
                        ESS.MODEL.M_MessageSend info = new ESS.MODEL.M_MessageSend();
                        info.send_seq = Convert.ToInt32(strForwordSendSeq);
                        info.message_status = "0";
                        info.updated_by = string.IsNullOrEmpty(strUserID) ? (int?)null : Int32.Parse(strUserID);
                        info.updated_when = DateTime.Now;
                        mesBLL.UpdateMessageStatus(info);
                    }
                    break;
                case "1":
                    strReplyText = "เห็นสมควรให้ลา";
                    strForwordSendSeq = CheckIsForword();

                    ESS.MODEL.M_MessageSend sendInfo = new ESS.MODEL.M_MessageSend();
                    sendInfo.send_seq = Convert.ToInt32(strForwordSendSeq);
                    sendInfo.message_status = "1";
                    sendInfo.updated_by = string.IsNullOrEmpty(strUserID) ? (int?)null : Int32.Parse(strUserID);
                    sendInfo.updated_when = DateTime.Now;
                    mesBLL.UpdateMessageStatus(sendInfo);
                    Reply();
                    break;
                case "2":
                    strReplyText = "เห็นสมควรให้ลา และรอการพิจารณาในขั้นต่อไป";
                    strForwordSendSeq = CheckIsForword();
                    InsertSend(Int32.Parse(strForwordSendSeq));
                    break;
            }
        }        
        
        protected void btnAddnew_Click(object sender, EventArgs e)
        {            
            reqBLL.InsertAbsence(cmbAbsenceType.SelectedValue
                , Session["EmpSeq"].ToString()
                , DateTime.Parse(txtStartDate.GetStringValue())
                , rdoStartTime.SelectedValue
                , DateTime.Parse(txtEndDate.GetStringValue())
                , rdoEndTime.SelectedValue
                , string.IsNullOrEmpty(txtCountDate.Text) ? 0 : decimal.Parse(txtCountDate.Text)
                , txtContactAddress.Text.Trim()
                , SystemInfo._WorkRecordStatus
                , cmbAppSeq.SelectedValue
                , ""
                , (DateTime?)null
                , 0
                , txtReason.Text.Trim()
                , Int32.Parse(Session["EmpSeq"].ToString()));

            lblAbsenceSeq.Text = reqBLL.GetAbsenceSequence().ToString();
            InsertSend((int?)null);
            LoadDataView(Int32.Parse(lblAbsenceSeq.Text));
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lblRefNo.Text.Trim()))
                return;
            else
                LoadDataView(Int32.Parse(lblAbsenceSeq.Text));
        }

        protected void cmbAbsenceType_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbAbsenceType.Items.Clear();

            DataSet ds = null;
            DataTable dt = null;

            ds = reqBLL.GetAbsenceTypes((int?)null, e.Text);

            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
            }

            int itemOffset = e.NumberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
            e.EndOfItems = (endOffset == dt.Rows.Count);
            //int j = 0;
            for (int i = itemOffset; i < endOffset; i++)
            {
                cmbAbsenceType.Items.Add(new RadComboBoxItem(dt.Rows[i]["ABSENCE_TYPE_NAME"].ToString(), dt.Rows[i]["ABSENCE_TYPE_SEQ"].ToString()));
                //j++;
            }
        }

        protected void cmbAppSeq_ItemsRequested1(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbAppSeq.Items.Clear();

            DataSet ds = null;
            ds = posBLL.GetPositionUpper(Int32.Parse(Session["EmpSeq"].ToString()), (int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {
                    cmbAppSeq.Items.Add(new RadComboBoxItem(dt.Rows[i]["FULL_NAME"].ToString(), dt.Rows[i]["UPPER_EMP_SEQ"].ToString()));
                    //j++;
                }
            }
        }

        protected void btnEditMode_Click(object sender, EventArgs e)
        {
            LoadDataEditInsert(Int32.Parse(lblAbsenceSeq.Text));
        }
        protected void btnBackHome_Click(object sender, EventArgs e)
        {
            ((Forms.RequestAbsences)this.Parent.Page).ViewGrid();            
        }

        protected void rdoApproveStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool bNotApproved = rdoApproveStatus.SelectedValue == "0";
            bool bNext = rdoApproveStatus.SelectedValue == "2";

            // กรณีไม่เห็นด้วย
            lblApprovedReasonTitle.Visible = bNotApproved;
            txtApprovedReason.Visible = bNotApproved;

            // กรณีส่งให้พิจารณาต่อ
            lblNextApprovedTitle.Visible = bNext;
            cmbNextApprover.Visible = bNext;
        }

        protected void cmbNextApprover_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbNextApprover.Items.Clear();

            DataSet ds = null;
            ds = posBLL.GetPositionUpper(Int32.Parse(lblApprovedBy.Text), (int?)null, e.Text);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];

                int itemOffset = e.NumberOfItems;
                int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
                e.EndOfItems = (endOffset == dt.Rows.Count);
                //int j = 0;
                for (int i = itemOffset; i < endOffset; i++)
                {
                    cmbNextApprover.Items.Add(new RadComboBoxItem(dt.Rows[i]["FULL_NAME"].ToString(), dt.Rows[i]["UPPER_EMP_SEQ"].ToString()));
                    //j++;
                }
            }
        }

        protected void btnViewRequest_Click(object sender, EventArgs e)
        {
            ((Forms.TaskLists)this.Parent.Page).ViewRequest();
        }
    }
}